package logic

import (
	"context"
	"person/model/mysql"
	"person/personrpc/internal/svc"
	"person/personrpc/personrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PersonAiUploadLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPersonAiUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PersonAiUploadLogic {
	return &PersonAiUploadLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PersonAiUploadLogic) PersonAiUpload(in *personrpc.PersonAiUploadRequest) (*personrpc.PersonAiUploadResponse, error) {
	// todo: add your logic here and delete this line
	ai := mysql.PersonAi{
		PersonId:            1,
		Name:                in.Name,
		MarriageAndMarriage: in.MarriageAndMarriage,
		IdImage:             in.IdImage,
		UserId:              in.UserId,
		Sex:                 in.Sex,
		DateOfBirth:         in.DateOfBirth,
	}
	mysql.DB.Debug().Create(&ai)
	return &personrpc.PersonAiUploadResponse{
		Id: int64(ai.ID),
	}, nil
}
